<!DOCTYPE html>
<html>
<head>
    <title>{$site_name}-会员中心-会员信息</title>
    <meta name="keywords" content="{$site_seo_keywords}" />
    <meta name="description" content="{$site_seo_description}">

    <style type="text/css">
        #two-con{
            width: 700px;
        }

        #two-con .control-label {
            float: left;
            width: 90px;
            padding-top: 5px;
            text-align: right;
        }
        #two-con input.span4{
            width: 200px;
        }
        #two-con select{
            height: 34px;
            line-height: 34px;
        }
        #two-con select.span4{
            width: 214px;
        }
        /*tips*/
        #two-con .help-inline {
            display: block;
            margin-bottom: -20px;
            *zoom: 1;
            font-size: 14px;
        }
        #two-con .controls {
            *display: inline-block;
            *padding-left: 20px;
            margin-left: 120px;
            *margin-left: 0
        }
    </style>
    <tc_include file="Public:head" />

</head>


<body class="body-white" id="top">
<tc_include file="Public:nav" />

<div class="container tc-main">
    <div class="row">
        <div class="span2">
            <tc_include file="Public:usernav"/>
        </div>
        <div class="span10">
            <ul class="nav nav-tabs">
                <li class="active"><a href="#">会员详情</a></li>
                <if condition="$userinfo['status'] eq 1"> <li><a href="{:leuu('User/Info/changecardnum', array('cardnum' => $userinfo['cardnum']))}">更换卡号</a></li></if>
                <li><a href="{:leuu('User/Info/storehis', array('cardnum' => $userinfo['cardnum']))}">消费历史</a></li>
            </ul>
            <form class="form-horizontal" id="dd" action="{:leuu('User/Info/edit')}">
                <div id="two-con">
                    <div style="float: left;">
                        <div class="control-group">
                            <label class="control-label" for="cardnum"><span style="color: red;">*</span>会员卡号:</label>
                            <div class="controls">
                                <input type="hidden" name="cardnum" value="{$userinfo.cardnum}">
                                <input type="text" id="cardnum" disabled name="cardnum2" value="{$userinfo.cardnum}" class="span4">
                                <span class="help-inline"></span>
                            </div>
                        </div>

                        <div class="control-group">
                            <label class="control-label" for="name">姓名:</label>
                            <div class="controls">
                                <input type="text" id="name" name="name" value="{$userinfo['name']}" class="span4" style="width: 120px;float: left;">
                                <select name="sex" id="sex" style="width: 70px;float: right;">
                                    <option value="1" <if condition="1 eq $userinfo['sex']">selected='selected'</if> >先生</option>
                                    <option value="2" <if condition="2 eq $userinfo['sex']">selected='selected'</if> >女士</option>
                                </select>
                                <span class="help-inline"></span>
                                <div style="clear: both;"></div>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label" for="tel">手机号码:</label>
                            <div class="controls">
                                <input type="text" id="tel" name="tel" value="{$userinfo['tel']}" class="span4">
                                <span class="help-inline"></span>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label" for="shenfenzheng">身份证号:</label>
                            <div class="controls">
                                <input type="text" id="shenfenzheng" value="{$userinfo['shenfenzheng']}" name="shenfenzheng" class="span4">
                                <span class="help-inline"></span>
                            </div>
                        </div>
                        <div class="control-group">
                            <label class="control-label" for="shengri">生日:</label>
                            <div class="controls">
                                <input type="text" id="shengri" name="shengri" value="{$userinfo['shengri']}" class="span4 js-date">
                                <span class="help-inline"></span>
                            </div>
                        </div>
                    </div>

                    <div style="float: right;">
                        <div class="control-group">
                            <label class="control-label" for="cardlevel"><span style="color: red;">*</span>会员级别:</label>
                            <div class="controls">
                                <select class="span4" name="cardlevel" id="cardlevel">
                                    <option value="0">请选择</option>
                                    <foreach name="cardlevel" item="val">

                                        <option value="{$val.id}"  <if condition="$val['id'] eq $userinfo['cardlevel']">selected='selected'</if> >{$val.cardname}</option>

                                    </foreach>
                                </select>

                                <span class="help-inline"></span>
                            </div>
                        </div>

                        <div class="control-group">
                            <label class="control-label" for="extensiontime">续合同日期:</label>
                            <div class="controls">
                                <if condition="'0000-00-00' eq $userinfo['extensiontime']">
                                    <input type="text" value="" name="extensiontime" class="span4 js-date">
                                    <else/>
                                    <input type="text" value="{$userinfo['extensiontime']}" name="extensiontime" class="span4 js-date">
                                </if>

                                <span class="help-inline"></span>
                            </div>
                        </div>

                        <div class="control-group">
                            <label class="control-label" for="upgradetime">升级时间:</label>
                            <div class="controls">
                                <if condition="'0000-00-00' eq $userinfo['upgradetime']">
                                    <input type="text"  value="" name="upgradetime" class="span4 js-date">
                                    <else/>
                                    <input type="text"  value="{$userinfo['upgradetime']}" name="upgradetime" class="span4 js-date">
                                </if>


                                <span class="help-inline"></span>
                            </div>
                        </div>

                        <div class="control-group">
                            <label class="control-label" for="createtime">开合同时间:</label>
                            <div class="controls">
                                <input type="text" id="createtime" disabled value="{$userinfo['createtime']}" name="createtime" class="span4">
                                <span class="help-inline"></span>
                            </div>
                        </div>

                        <div class="control-group">
                            <label class="control-label" for="totalstore">卡内余额:</label>
                            <div class="controls">
                                <input type="text" id="totalstore" disabled="disabled" name="totalstore" value="{$userinfo['totalstore']/100}" class="span4">
                                <span class="help-inline"></span>
                            </div>
                        </div>

                    </div>
                    <div style="clear: both"></div>

                    <div class="control-group">
                        <label class="control-label" for="address">床位信息:</label>
                        <div class="controls">

                            <if condition="$userinfo['usetime']">
                                <input type="text" name="show" value="{$userinfo['areaname']}-{$userinfo.housename}-{$userinfo.floorname}-{$userinfo.roomname}-{$userinfo.bedname}-{$userinfo.usetime}个月 " style="width: 570px;">
                                <else/>

                                <input type="text" name="show" value="无选择的床位信息" style="width: 570px;">

                            </if>
                            <span class="help-inline"></span>
                        </div>
                    </div>

                    <div class="control-group">

                        <label class="control-label">联系地址:</label>

                        <div class="controls">

                            <select name="province" id="province" style="width: 120px">

                                <option value="0">--省份--</option>

                                <foreach name="province" item="val">

                                    <option value="{$val.region_id}" data-id="{$val.region_id}" <if condition="$val['region_id'] eq $userinfo['province']">selected='selected'</if> >{$val.name}</option>

                                </foreach>

                            </select>

                            <select name="city" id="city" style="width: 120px;margin-left: 10px">

                                <foreach name="city" item="val">

                                    <option value="{$val.region_id}" data-id="{$val.region_id}" <if condition="$val['region_id'] eq $userinfo['city']">selected='selected'</if> >{$val.name}</option>

                                </foreach>

                            </select>

                            <select name="local" id="local" style="width: 120px;margin-left: 10px">

                                <foreach name="local" item="val">

                                    <option value="{$val.region_id}" data-id="{$val.region_id}" <if condition="$val['region_id'] eq $userinfo['local']">selected='selected'</if> >{$val.name}</option>

                                </foreach>

                            </select>
                            <input type="text" placeholder="工作人员" id="yewuyuan" name="yewuyuan" value="{$userinfo['yewuyuan']}" style="width: 160px;margin-left: 10px">
                        </div>

                    </div>
                    <div class="control-group">
                        <label class="control-label" for="address">详细地址:</label>
                        <div class="controls">
                            <input type="text" id="address" name="address" value="{$userinfo['address']}" style="width: 570px;">
                            <span class="help-inline"></span>
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label" for="remark">备注:</label>
                        <div class="controls">
                            <textarea  id="remark" name="remark"  style="width: 570px;height: 80px">{$userinfo['remark']}</textarea>
                            <span class="help-inline"></span>
                        </div>
                    </div>
                </div>


                <if condition="$userinfo['status'] eq 1">
                    <div class="control-group" style="margin-top: 50px;">
                        <label class="control-label" for=""></label>
                        <div class="controls">
                            <button class="btn btn-primary js-ajax-submit span4" type="button" style="margin-left: 0px" id="subbtn">保存</button>
                        </div>
                    </div>
                </if>


            </form>
        </div>



    </div>
    <tc_include file="Public:footer" />
</div>
<!-- /container -->
<tc_include file="Public:scripts" />
<script type="text/javascript">
    //编辑器路径定义
    var editorURL = GV.DIMAUB;
</script>

<script type="text/javascript">
    $('#subbtn').click(function() {

        $.post("{:leuu('User/Info/edit')}",$('#dd').serialize(),function(data) {
            document.getElementById('subbtn').disabled=true;
            if(data.status == 1) {
                if(data.url) {
                    window.location.href=data.url;
                } else {
                    location.reload();
                }
            } else {
                alert(data.info);
                document.getElementById('subbtn').disabled=false;
            }
        })
    });


    // 验证身份证
    function isCardNo(card) {
        var pattern = /(^\d{15}$)|(^\d{18}$)|(^\d{17}(\d|X|x)$)/;
        return pattern.test(card);
    }

    function GetBirthdatByIdNo(iIdNo){
        if(!isCardNo(iIdNo)){
            alert('请输入正确身份证号码！');
            return;
        }
        var tmpStr = "";
        iIdNo = $.trim(iIdNo);
        if(iIdNo.length == 15){
            tmpStr = iIdNo.substring(6, 12);
            tmpStr = "19" + tmpStr;
            tmpStr = tmpStr.substring(0, 4) + "年" + tmpStr.substring(4, 6) + "月" + tmpStr.substring(6) + "日";
            var sexStr = parseInt(iIdNo.substring(14, 1),10) % 2 ? "1" : "2";
            $('#shengri').val(tmpStr);
            $('#sex').val(sexStr);
        }else{
            tmpStr = iIdNo.substring(6, 14);
            tmpStr = tmpStr.substring(0, 4) + "年" + tmpStr.substring(4, 6) + "月" + tmpStr.substring(6) + "日";
            var sexStr = parseInt(iIdNo.substring(17, 1),10) % 2 ? "1" : "2";
            $('#shengri').val(tmpStr);
            $('#sex').val(sexStr);
        }
    }
    $("#shenfenzheng").blur(function(){
        GetBirthdatByIdNo($(this).val());
    });

    $('#province').change(function() {

        var v = $(this).find(':selected').data('id');

        $.post("{:leuu('Qrcode/center/get_region')}",{pid:v},function(data) {

            $('#city').empty();

            $('#city').append('<option  value="0">--地区--</option>');

            if(data.length > 0) {

                for(var i=0;i<data.length;i++) {

                    $('#city').append('<option data-id="'+data[i].region_id+'" value="'+data[i].name+'">'+data[i].name+'</option>');

                }

            }

        },'json');

    });

    $('#city').change(function() {

        var v = $(this).find(':selected').data('id');

        $.post("{:leuu('Qrcode/center/get_region')}",{pid:v},function(data) {

            $('#local').empty();

            $('#local').append('<option  value="0">--城市--</option>');


            if(data.length > 0) {

                for(var i=0;i<data.length;i++) {

                    $('#local').append('<option value="'+data[i].name+'">'+data[i].name+'</option>');

                }

            }

        },'json');

    });

</script>
</body>
</html>